# Definition for a binary tree node.
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution:
    def searchBST(self, root: TreeNode, val: int) -> TreeNode:
        while root:
           if root.val == val:
               return root
           elif root.val > val:
               root = root.left
           elif root.val < val:
                root  = root.right
        else:
            return None
